<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="逆向工程–自动生成java类和xml文件首先pom.xml中添加maven插件()      &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt;                 &lt;groupId&gt;org.mybatis.generator&lt;&#x2F;groupId&gt;                 &lt;artifactId&gt;mybat">
<meta property="og:type" content="website">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="https://gitee.com/lacquer_seven/lacquer_seven.io/%E6%88%91%E7%9A%84%E7%AC%AC%E4%BA%8C%E7%AF%87%E5%8D%9A%E5%AE%A2/firstBlog.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="逆向工程–自动生成java类和xml文件首先pom.xml中添加maven插件()      &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt;                 &lt;groupId&gt;org.mybatis.generator&lt;&#x2F;groupId&gt;                 &lt;artifactId&gt;mybat">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-05-21T12:06:42.087Z">
<meta property="article:modified_time" content="2020-05-21T12:06:42.087Z">
<meta property="article:author" content="John Doe">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/lacquer_seven.io/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/lacquer_seven.io/css/style.css">

<meta name="generator" content="Hexo 4.2.1"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/lacquer_seven.io/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/lacquer_seven.io/">Home</a>
        
          <a class="main-nav-link" href="/lacquer_seven.io/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/lacquer_seven.io/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://gitee.com/lacquer_seven/lacquer_seven.io"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="page-" class="article article-type-page" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/lacquer_seven.io/%E6%88%91%E7%9A%84%E7%AC%AC%E4%BA%8C%E7%AF%87%E5%8D%9A%E5%AE%A2/firstBlog.html" class="article-date">
  <time datetime="2020-05-21T12:06:42.087Z" itemprop="datePublished">2020-05-21</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="逆向工程–自动生成java类和xml文件"><a href="#逆向工程–自动生成java类和xml文件" class="headerlink" title="逆向工程–自动生成java类和xml文件"></a>逆向工程–自动生成java类和xml文件</h1><p><strong>首先pom.xml中添加maven插件</strong><br>(<code>)
     &lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
                &lt;groupId&gt;org.mybatis.generator&lt;/groupId&gt;
                &lt;artifactId&gt;mybatis-generator-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;1.3.5&lt;/version&gt;
                &lt;dependencies&gt;
                    &lt;dependency&gt;
                        &lt;groupId&gt; mysql&lt;/groupId&gt;
                        &lt;artifactId&gt; mysql-connector-java&lt;/artifactId&gt;
                        &lt;version&gt; 8.0.11&lt;/version&gt;
                    &lt;/dependency&gt;
                    &lt;dependency&gt;
                        &lt;groupId&gt;org.mybatis.generator&lt;/groupId&gt;
                        &lt;artifactId&gt;mybatis-generator-core&lt;/artifactId&gt;
                        &lt;version&gt;1.3.5&lt;/version&gt;
                    &lt;/dependency&gt;
                &lt;/dependencies&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;id&gt;Generate MyBatis Artifacts&lt;/id&gt;
                        &lt;phase&gt;package&lt;/phase&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;generate&lt;/goal&gt;
                        &lt;/goals&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
                &lt;configuration&gt;
                    &lt;!--允许移动生成的文件 --&gt;
                    &lt;verbose&gt;true&lt;/verbose&gt;
                    &lt;!-- 是否覆盖 --&gt;
                    &lt;overwrite&gt;true&lt;/overwrite&gt;
                    &lt;!-- 自动生成的配置 --&gt;
                    &lt;configurationFile&gt;
                        src/main/resources/mybatis-generator.xml&lt;/configurationFile&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
(</code>)</p>
<p><strong>在resources下创建mybatis-generator.xml</strong><br>(```)<br><?xml version="1.0" encoding="UTF-8"?><br><!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"><br><generatorConfiguration></p>
<pre><code>&lt;context id=&quot;DB2Tables&quot;    targetRuntime=&quot;MyBatis3&quot;&gt;
    &lt;commentGenerator&gt;
        &lt;property name=&quot;suppressDate&quot; value=&quot;true&quot;/&gt;
        &lt;property name=&quot;suppressAllComments&quot; value=&quot;true&quot;/&gt;
    &lt;/commentGenerator&gt;
    &lt;!--数据库链接地址账号密码--&gt;
    &lt;jdbcConnection driverClass=&quot;com.mysql.jdbc.Driver&quot; connectionURL=&quot;jdbc:mysql://rm-wz9lf9viya8mxh9vwgo.mysql.rds.aliyuncs.com:3306/ge&quot; userId=&quot;geroot&quot; password=&quot;Ge20202020&quot;&gt;
    &lt;/jdbcConnection&gt;
    &lt;javaTypeResolver&gt;
        &lt;property name=&quot;forceBigDecimals&quot; value=&quot;false&quot;/&gt;
    &lt;/javaTypeResolver&gt;
    &lt;!--生成Model类存放位置--&gt;
    &lt;javaModelGenerator targetPackage=&quot;com.tz.domain&quot; targetProject=&quot;src/main/java&quot;&gt;
        &lt;property name=&quot;enableSubPackages&quot; value=&quot;true&quot;/&gt;
        &lt;property name=&quot;trimStrings&quot; value=&quot;true&quot;/&gt;
    &lt;/javaModelGenerator&gt;
    &lt;!--生成映射文件存放位置--&gt;
    &lt;sqlMapGenerator targetPackage=&quot;com.tz.mapper&quot; targetProject=&quot;src/main/resources&quot;&gt;
        &lt;property name=&quot;enableSubPackages&quot; value=&quot;true&quot;/&gt;
    &lt;/sqlMapGenerator&gt;
    &lt;!--生成Dao类存放位置--&gt;
    &lt;!-- 客户端代码，生成易于使用的针对Model对象和XML配置文件 的代码
            type=&quot;ANNOTATEDMAPPER&quot;,生成Java Model 和基于注解的Mapper对象
            type=&quot;MIXEDMAPPER&quot;,生成基于注解的Java Model 和相应的Mapper对象
            type=&quot;XMLMAPPER&quot;,生成SQLMap XML文件和独立的Mapper接口
    --&gt;
    &lt;javaClientGenerator type=&quot;XMLMAPPER&quot; targetPackage=&quot;com.tz.mapper&quot; targetProject=&quot;src/main/java&quot;&gt;
        &lt;property name=&quot;enableSubPackages&quot; value=&quot;true&quot;/&gt;
    &lt;/javaClientGenerator&gt;
    &lt;!--生成对应表及类名--&gt;
    &lt;table tableName=&quot;sys_currency_timing&quot; domainObjectName=&quot;SysCurrencyTiming&quot; enableCountByExample=&quot;false&quot; enableUpdateByExample=&quot;false&quot; enableDeleteByExample=&quot;false&quot; enableSelectByExample=&quot;false&quot; selectByExampleQueryId=&quot;false&quot;&gt;&lt;/table&gt;
&lt;/context&gt;</code></pre></generatorConfiguration>
(```)
      
    </div>
    <footer class="article-footer">
      <a data-url="https://gitee.com/lacquer_seven/lacquer_seven.io/%E6%88%91%E7%9A%84%E7%AC%AC%E4%BA%8C%E7%AF%87%E5%8D%9A%E5%AE%A2/firstBlog.html" data-id="ckalxw4ic00012ovvgws6gwj6" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/lacquer_seven.io/archives/2020/05/">May 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/lacquer_seven.io/2020/05/21/%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E7%AF%87%E5%8D%9A%E5%AE%A2/">我的第一篇博客</a>
          </li>
        
          <li>
            <a href="/lacquer_seven.io/2020/05/21/hello-world/">Hello World</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/lacquer_seven.io/" class="mobile-nav-link">Home</a>
  
    <a href="/lacquer_seven.io/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/lacquer_seven.io/fancybox/jquery.fancybox.css">

  
<script src="/lacquer_seven.io/fancybox/jquery.fancybox.pack.js"></script>




<script src="/lacquer_seven.io/js/script.js"></script>




  </div>
</body>
</html>